﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SIPO.master" AutoEventWireup="false" CodeFile="recMonitoringPostJurnal.aspx.cs" Inherits="SIPO.Web.Lists.Transaction.recMonitoringPostJurnal" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" Runat="Server">
 <link type="text/css" rel="stylesheet" href="<%= ResolveUrl("~/styles/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/i18n/grid.locale-id.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/jquery.jqGrid.min.js") %>"></script>

    
  <script type="text/javascript">
      $(document).ready(function () {
          $("#btnCancel").button({ icons: { primary: "ui-icon-close"} });
          $("#btnSubmit").button({ icons: { primary: "ui-icon-circle-arrow-e"} });

          $("#btnCancel").click(function () {
        $("#<%= ddlPeriode1.ClientID %>").val('Periode Awal');
         $("#<%= ddlPeriode2.ClientID %>").val('Periode Akhir');
         


          });

          //          $("#btnPrint").click(function () {
          //              var formUrl = '<%= ResolveUrl("~/lists/Report/rptVoucherPrint.aspx") %>';

          //              var grid = $('#table');
          //              var selIds = grid.jqGrid('getGridParam', 'selarrrow'),
          //                selText = [];
          //              $.each(selIds, function () {
          //                  selText.push(grid.jqGrid('getCell', this, 'BillingNo'));
          //              });
          //              if (selIds.length == 0) {
          //                  alert('Pilih data yang akan di cetak !');
          //              }
          //              else if (selIds.length > 1) {
          //                  alert('Pilih satu record untuk cetak voucher !');
          //              }
          //              else {
          //                  window.open(formUrl + "?id=" + selText);
          //              }
          //          });



       
       


          var handleUrl = 'nothing'; //agar saat load data tidak muncul
          var url1 = '<%= ResolveUrl("~/AjaxHandler/Transaction/recJurnalhandler.ashx") %>';
          $('#table').jqGrid({
              url: handleUrl,
              datatype: 'json',
              colNames: ['NoTrans', 'Nama Debitur', 'Tanggal Transaksi', 'Jenis Transaksi'],
              colModel: [
                { name: 'JurnalCode', hidden: true, index: 'jurnalcode', align: 'center', width: 200 },
           		{ name: 'nama', index: 'nama', align: 'center', width: 200 },
                { name: 'tglposting', index: 'tglposting', align: 'center', width: 115, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
           	    { name: 'jmlrptrans', index: 'jmlrptrans', align: 'right', searchoptions: { sopt: ['eq', 'cn'] }, width: 200, formatter: 'currency', formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2} },
                         	],
              rowNum: 10,
              id: 'jurnalcode',
              multiselect: false,
              rowList: [5, 10, 15, 20],
              pager: '#pager',
              sortname: 'tgl_posting',
              sortorder: "asc",
              viewrecords: true,
              jsonReader: { repeatitems: false },
              width: 750,
              height: '100%',
              caption: 'Monitoring Posting Jurnal',
              ajaxGridOptions: { cache: false },
              subGrid: true,
              subGridRowExpanded: function (subgrid_id, row_id) {
                  var rowData = $("#table").getRowData(row_id);
                 var a = rowData['JurnalCode'];
                 // alert(url1 + '?method=getdatadetail&id=' + row_id);
                  var subgrid_table_id, pager_id;
                  subgrid_table_id = subgrid_id + "_t";
                  pager_id = "p_" + subgrid_table_id;
                  $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "'class='scroll'></table><div id='" + pager_id + "'class='scroll'></div>");
                  $("#" + subgrid_table_id).jqGrid({
                      url: url1 + '?method=getdatadetail&id=' + a,
                      datatype: 'json',
                      mtype: 'POST',
                      colNames: ['Kode Buku Besar','Keterangan', 'Debet', 'Kredit'],
                      colModel: [
                        { name: "kdbukubesar", index: "JurnalDetailID", width: 100, key: true, hide: true,align:"center"},
                      //                        {name:"recDemandDetail.TransNo",index:"TransNo",width:100},
                        {name:"bukubesarname",index:"bukubesarname",width:250,align:"left"},
                        {name: 'saldovaldebet', index: 'saldo_val_debet', formatter: 'currency', align: 'right', formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2 }, width: 145 },
                       { name: 'saldovalkredit', index: 'saldo_val_kredit', formatter: 'currency', align: 'right', formatoptions: { decimalSeparator: ".", thousandsSeparator: ",", decimalPlaces: 2 }, width: 145 }

                    ],
                      rowNum: 20,
                     // pager: pager_id,
                      sortname: 'kdbukubesar',
                      sortorder: "asc",
                      viewrecords: true,
                      height: '100%'
                  });
               //   $("#" + subgrid_table_id).jqGrid('navGrid', "#" + pager_id, { edit: false, add: false, del: false, search: false })
              }
              //              ondblClickRow: function () {
              //                  //                OpenForm('edit');
              //              }
          });






          $("#btnSubmit").click(function () {

              var periodeawal = $("#<%= ddlPeriode1.ClientID %>").val();
              var periodeakhir = $("#<%= ddlPeriode2.ClientID %>").val();

              if (periodeawal.toString().toLowerCase().indexOf('awal') < 0 && periodeakhir.toString().toLowerCase().indexOf('akhir') < 0) {

                  jQuery("#table").setGridParam({ url: '<%= ResolveUrl("~/AjaxHandler/Transaction/recJurnalhandler.ashx") %>' + '?method=getdata&periodeawal=' + periodeawal + '&periodeakhir=' + periodeakhir});
                  jQuery("#table").trigger("reloadGrid", [{ page: 1}]);

              }
              
              else {
                  if (periodeawal.toString().toLowerCase().indexOf('2') < 0 && periodeakhir.toString().toLowerCase().indexOf('2') < 0) {

                      jQuery("#table").setGridParam({ url: '<%= ResolveUrl("~/AjaxHandler/Transaction/recJurnalhandler.ashx") %>' + '?method=getdata&periodeawal=&periodeakhir=' });
                      jQuery("#table").trigger("reloadGrid", [{ page: 1}]);
                  }
                  else  {
                      alert('Periode tanggal tidak valid !');
                  }
              }
          });

      });
    </script>
<table border="0">
<tr>
            <td style="width: 51px; text-align: left; height: 38px;">
           
                        Periode
                    </td>
            <td style="height: 38px; width: 15px;">
                        :
                    </td>
            <td align="left" style="height: 38px">
                <asp:DropDownList ID="ddlPeriode1" runat="server" Height="22px" Width="130px">
                </asp:DropDownList>
&nbsp;s/d
                        <asp:DropDownList ID="ddlPeriode2" runat="server" Height="22px" 
                    Width="130px">
                </asp:DropDownList>
&nbsp;<br />
            </td>

        </tr>

        </table>
        <br />
     <button class="dialog_link ui-state-default ui-corner-all" id="btnSubmit" type="button">
                        Lanjut
                    </button>   
                     <button class="dialog_link ui-state-default ui-corner-all" id="btnCancel" type="button">
                        Batal
                    </button>
    <br />
    <br />
    <table id="table" class="scroll" cellpadding="0" cellspacing="0""  >
    
    </table>
    <div id="pager" class="scroll">
    </div>
    <br />
    <div id="dialog" title="Default dialog">
    </div>
    
     
</asp:Content>

